<?php
class outputMenu
{
  var $json_array = array();
  var $result = '';

  function outputMenu()
  {
    include('../../data/data.php');
    $this -> getMenu();
  }

  function getMenu()
  {
    $sql = 'SELECT * FROM menu JOIN menutype on menu.id_menuType = menutype.id and menutype.id_restaurant = 1';
    $this -> result = mysql_query($sql) or die("zxcv");

    if ( mysql_num_rows($this -> result) > 0 )
    {
      for ( $i = 0; $i < mysql_num_rows($this -> result); ++$i )
      {
        $path = 'http://ewaiter.info/'.mysql_result($this -> result,$i,'Image').mysql_result($this -> result,$i,'imageName');
        $this -> json_array[$i] = array( 'name' => mysql_result($this -> result,$i,'name'), 'shortDescription' => mysql_result($this -> result,$i,'shortDescription'),'path' => $path);
      }
    }
    $this -> json_array[ mysql_num_rows($this -> result) ] = $this -> json_array[ mysql_num_rows($this -> result) - 1 ];
    print( str_replace('\/','/',json_encode($this -> json_array)) );
  }
}

$obj = new outputMenu();
?>